<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function flat(arr){
            //判断是不是数组
            if(!Array.isArray(arr)){
                return arr
            }
            return arr.reduce(function(p,c){
                return p.concat(flat(c))
            },[])
        }
    </script>
</body>
</html>